<%@page import="java.text.SimpleDateFormat" %>
<%@page import="beans.PersonAssignment"%>
<%@page import="beans.TaskMetrics"%>
<%@page import="beans.Skill" %>

<jsp:useBean id="projectId" type="java.lang.Integer" scope="request"/>
<jsp:useBean id="people" type="java.util.List" scope="request"/>
<jsp:useBean id="metrics" type="java.util.List" scope="request"/>
<jsp:useBean id="skills" type="java.util.List" scope="request"/>

<% 
	SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
%>

<html>
<body>
<table border="1">
<tr><td>
<h4>Add Task</h4>
<form method="post" action="PmServlet">
	Sequence: <input type="number" name="sequence"/><br>
	Description: <input type="text" size="30" name="description"/><br>
	<input type="submit" value="Add Task"/><input type="reset"/>
	<input type="hidden" name="act" value="addTask" />
	<input type="hidden" name="projectId" value="<%=projectId%>"/>
</form>
</td></tr>
</table>
<h4>Assigned People</h4>
<table border="1">
<tr><th>Email</th><th>Percent</th><th>Start</th><th>End</th></tr>
<%
for(int i = 0; i < people.size(); i++) {
	PersonAssignment p = (PersonAssignment)people.get(i);
	String startDate = sf.format(p.startDate.getTime());
	String endDate = sf.format(p.endDate.getTime());
%>
	<tr><td><%=p.person.email%></td><td><%=p.percent%></td><td><%=startDate%></td><td><%=endDate%></td></tr>
<%
}
%>
</table>

<h4>Tasks</h4>
<form action="PmServlet" method="post">
<table border="1">
<tr><th>&nbsp;</th><th>Sequence</th><th>Task</th><th>Status</th><th>Number of Skills</th><th>Number of Resources</th></tr>
<%
for(int i = 0; i < metrics.size(); i++) {
	TaskMetrics t = (TaskMetrics)metrics.get(i);
%>
	<tr><td><input type="radio" name="taskId" value="<%= t.taskId %>"></td><td><%=t.sequence %></td><td><%=t.description%></td><td><%=t.status%></td><td><%=t.numberOfSkills%></td><td><%=t.numberOfResources%></td></tr>
<%	
}
%>
</table>
<p>Add Skill:
<select name="skillId">
<%  for (int i = 0; i < skills.size(); i++) { %>
<%    Skill s = (Skill) skills.get(i);    %>
	  <option value="<%= s.id %>"><%=s.description %></option>
<%  } %>
</select>

Start Date: <input type="text" size="10" maxlength="10" name="startDate"/>
End Date: <input type="text" size="10" maxlength="10" name="endDate"/>
Level: <input type="text" size="3" maxlength="3"name="level"/>
Percent: <input type="text" size="3" maxlength="3" name="percent"/>
<input type="hidden" name="projectId" value="<%=projectId%>"/>
<input type="hidden" name="act" value="assignSkillToTask"/>
<input type="submit" value="Assign to Task"/>
</form>

</body>
</html>